<template>
  <div id="app">
    <moments-header />
      <keep-alive>
          <router-view></router-view>
      </keep-alive>
  </div>
</template>

<script>
import MomentsHeader from './components/MomentsHeader'
import RemoteDAO from './tools/remoteDAO'
import axios from 'axios'
import {mapActions} from 'vuex'

const invoke = function (interfaceStr, params) {
  console.log(interfaceStr)
  return new Promise((resolve, reject) => {
    axios({
      method: 'post',
      url: 'http://10.176.118.55:7003/sjjp/' + interfaceStr,
      // data: cache.checkBuffer(interfaceStr, params),
      timeout: 5000
    })
    .then(result => {
      console.log(result)
      // let data = cache.updateBuffer(interfaceStr, params, result.data);
      resolve(result.data)
    })
    .catch(error => {
      reject(error)
    })
  })
}

export default {
  name: 'app',
  components: {
    MomentsHeader
  },
  mounted () {
    console.log('this.messagebox', this.$MessageBox)
    this.$MessageBox('wefwf')
    invoke('1018', 0).then(res => {
      console.log(res)
    })
    this.fetchSetting()
  },
  methods: {
    ...mapActions(['setSettingEnable']),
    setStoreSetting (name, value) {
      let storeParams = {
        name: name,
        value: value
      }
      this.setSettingEnable(storeParams)
    },
    fetchSetting () {
      let params = {
        userCode: localStorage.getItem('userCode')
      }
      RemoteDAO.queryUserConfig(params)
      .then(res => {
        let setArr = res.data.body.body.result
        setArr.forEach(item => this.setStoreSetting(item, false))
      }, err => {
        console.warn(err)
      })
    }
  }
}
</script>

<style lang="less">
@import 'assets/css/reset.css';
@import 'assets/css/iconfont.css';
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: rgb(241,243,246);
  ::-webkit-scrollbar {
    display: none;
  }
}


#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}


</style>
